(define-module (basket path)
               #:use-module (basket)
               #:use-module (srfi srfi-1))

(export
  path?
  cpath?
  cpath->path
  path->lines)

(define (path? p)
  (and (list? p)
       (>= (length p) 1)
       (every vec? p)))

(define (cpath? p)
  (or (path? p)
      (and (list? p)
           (>= (length p) 1)
           (eq? (car p) 'cpath))))

(define (cpath->path p)
  (append (cdr p) (list (cadr p))))

(define cpath->poly cdr)

(define (path->lines p)
  (map list p (cdr p)))
